package com.weng.cloud.service8881.retry;

import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: weng
 * @Date: 2022/3/9
 * @Description: com.weng.cloud.service8881.retry
 */
@RestController
public class RetryController {

    /**
     * <br/>function:
     * <br/>tip:
     *
     * @param: []
     * @return: java.lang.String
     * @author: weng
     * @date: 2022/3/9 21:24
     *
     */
    @GetMapping("/testSpringRetry")
    //@Retryable
    @Retryable(maxAttempts = 6,backoff = @Backoff(value = 10000))
    public String testSpringRetry(){
        System.err.println("哒咩唷~");
        this.doRetry();
        return "讲道理不应该像这样走完的...";
    }

    //方法内部调用，会使aspect增强失效
    //@Retryable
    private void doRetry(){
        int i = 1 / 0;
    }

    //@Recover是标记注解，内部没有任何属性
    @Recover
    private String doRecover(){
        return "踏踏开！！！嘶嘶咩！！！";
    }
}
